<h1>Nos produits complémentaires</h1>
<div class="cadreContenu">
	<?php 
		require_once ('../connexion.php');
	// Selection de l'id de la page prodCompl
		try{
			$sql = 'SELECT id FROM pages WHERE titre=:prodCompl';
			$select = $connection->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
			$select->execute(array(':prodCompl' => 'Produits complémentaires'));
			$enregistrement = $select->fetch(PDO::FETCH_OBJ);
	
			if($enregistrement==true){
			//Selection des parties de la page
				try{
					$sqlLimit = 'SELECT * FROM images WHERE idTypesProd=3 LIMIT 1';
					$select2 = $connection->prepare($sqlLimit, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
					$select2->execute();
					$enregistrement2=$select2->fetch(PDO::FETCH_OBJ);
					
					$chemin=$enregistrement2->chemin;
					$nom=$enregistrement2->nom;
					$descri=$enregistrement2->description;
				}catch(Exception $e){
					echo "<h3 class='error'>Impossible de charger le contenu</h3>";
				}
				
				try{
					$sql3 = 'SELECT * FROM images WHERE idTypesProd=3';
					$select3 = $connection->prepare($sql3, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
					$select3->execute();
					
					
				
		?>			
					<table class="thumbnail">
						<tr>
							<td class="thumbnailContent">
								<div id="divLargeImg">
									<img id="imgContent" src="images/<?php echo $chemin;?>"/>
								</div>
								<h3 id="h3Description" class="titleDescriptionGalery"><?php echo $nom;?></h3>
								<p id="descriptionGalerry"><?php echo $descri;?></p>
							</td>
							<td class="thumbnailChoice">	
								<?php
								while($enregistrement3 = $select3->fetch(PDO::FETCH_OBJ)){
									$nom=preg_replace('/"/','&#34;',$enregistrement3->nom); // convertie toutes les "
									$nom=preg_replace('/\'/','&#180;',$nom); // convertie toutes les '
									
									$description=preg_replace('/"/','&#34;',$enregistrement3->description); // convertie toutes les "
									$description=preg_replace('/\'/','&#180;',$description); // convertie toutes les '
								?>
									<div>	
										<img onMouseOver="return loadLargeImage('<?php echo $enregistrement3->chemin;?>','<?php echo $description;?>','<?php echo $nom;?>');" class="littleImage" src="images/<?php echo $enregistrement3->chemin;?>" />					
									</div>
								<?php
								}						
								?>					
							</td>			
						</tr>
					</table>			
		<?php
				}catch(Exception $e){
					echo "<h3 class='error'>Impossible de charger le contenu</h3>";
				}
			
			try{
				$sql4 = 'SELECT * FROM partie WHERE idPages=:idPages ORDER BY ordre';
				$select4 = $connection->prepare($sql4, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
				$select4->execute(array(':idPages' => $enregistrement->id ));
				while( $enregistrement4 = $select4->fetch(PDO::FETCH_OBJ) )
					{?>
						<h1><?php echo $enregistrement4->titre;?></h1>
						<?php 
						if ($enregistrement4->idImages!=null){
							$sql5 = 'SELECT * FROM images WHERE id=:idImages';
							$select5 = $connection->prepare($sql5, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
							$select5->execute(array(':idImages' => $enregistrement4->idImages ));
							$enregistrement5 = $select5->fetch(PDO::FETCH_OBJ);
							
							if($enregistrement5){?>
							<div class="imgCenter">
								<div class="imgCenter2"><img id="imgBIG" src="images/<?php echo $enregistrement5->chemin;?>"/></div></div>
							<?php
							}
						}
						?>
						<p><?php echo $enregistrement4->contenu;?></p>
					<?php
					}
				}catch(Exception $e){
					echo "<h3 class='error'>Impossible de charger le contenu</h3>";
				}
		}
	}catch(Exception $e){
		echo "<h3 class='error'>Impossible de charger cette page</h3>";
	}
							
	?>
</div>